from datetime import datetime
from typing import Optional, List, Dict, Any
from pydantic import BaseModel, Field
from app.models.minutes import MinutesStatus


class MinutesBase(BaseModel):
    """会议纪要基础模型"""
    title: str = Field(..., min_length=1, max_length=200)
    summary: Optional[str] = Field(None, max_length=2000)
    key_points: Optional[List[str]] = Field(default_factory=list)
    decisions: Optional[List[str]] = Field(default_factory=list)
    action_items: Optional[List[Dict[str, Any]]] = Field(default_factory=list)
    template_name: Optional[str] = None
    attendees: Optional[List[str]] = Field(default_factory=list)
    meeting_time: Optional[datetime] = None


class MinutesCreate(MinutesBase):
    """创建会议纪要请求模型"""
    meeting_id: int


class MinutesUpdate(BaseModel):
    """更新会议纪要请求模型"""
    title: Optional[str] = Field(None, min_length=1, max_length=200)
    summary: Optional[str] = Field(None, max_length=2000)
    key_points: Optional[List[str]] = None
    decisions: Optional[List[str]] = None
    action_items: Optional[List[Dict[str, Any]]] = None
    content: Optional[str] = None
    status: Optional[MinutesStatus] = None
    attendees: Optional[List[str]] = None
    meeting_time: Optional[datetime] = None


class Minutes(MinutesBase):
    """会议纪要响应模型"""
    id: int
    meeting_id: int
    content: Optional[str] = None
    status: MinutesStatus
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True


class MinutesGenerationRequest(BaseModel):
    """会议纪要生成请求模型"""
    meeting_id: int
    template_name: Optional[str] = "default"
    custom_prompt: Optional[str] = None


class MinutesExportRequest(BaseModel):
    """会议纪要导出请求模型"""
    format: str = Field(..., regex="^(pdf|docx|markdown)$")
    template: Optional[str] = None